/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session_03_states.estados;

import org.newdawn.slick.BigImage;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author Fede
 */
public class Juego extends BasicGameState {

    private int xImg = 0,yImg = 0,xFondo=0;
    private Image imgFede;
    private Image imgFondo;
    private Input entrada;

    public Juego() throws SlickException {
    }

    @Override
    public int getID() {
        return Estados.JUEGO;
    }

    @Override
    public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
        entrada = gc.getInput();
        imgFede = new Image("res/fede.jpg");
        imgFondo = new BigImage("res/fondo.jpg");
    }

    @Override
    public void render(GameContainer gc, StateBasedGame sbg, Graphics grphcs) throws SlickException {
        imgFondo.draw(xFondo, 0);
        
        if (entrada.isKeyDown(Input.KEY_RIGHT)){
            //xImg++;
            xFondo--;
        }
        if (entrada.isKeyDown(Input.KEY_LEFT)){
            //xImg--;
            xFondo++;
        }
        if (entrada.isKeyDown(Input.KEY_DOWN)){
            yImg++;
        }
        if (entrada.isKeyDown(Input.KEY_UP)){
            yImg--;
        }
        
        if(entrada.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)){
            xImg = entrada.getMouseX() - (imgFede.getWidth()/2);
            yImg = entrada.getMouseY() - (imgFede.getHeight()/2);
        }
            imgFede.draw(xImg, yImg);
       
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
        
    }
}
